import { activityDetail } from '../../utils/getData.js'
import { picUrl, launchAppCopy } from '../../utils/util.js';
const getopen = require('../../utils/maxutil.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    title:'',
    typename:'',
    type:1,
    join:false,
    activityCoverPage:'',
    source:0,//来源1首页跳入
    headerType:4, //
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    // let activityId = 'd794ef18aaf642b1a549c4627870f7e1'
    this.getdata(options.activityId)
    this.setData({
     type:options.status,
    //  source:options.source? options.source :0,
     headerType:options.source ? options.source :4
    })
  },

  getdata(activityId){
    let than = this;
    let data = {
      activityId:activityId,
      userId:wx.getStorageSync('userId') || '' //微信获取，非必填项
    }
    activityDetail(data).then(res => {
      console.log(res)
      let data = res.result;
      if(res.success){
        than.setData({
          title:res.result.activityName,
          join:data.join,
          activityJoinType:data.activityJoinType,//是否需要申请 0无需申请，1申请 
          // typename:data.join ? '已加入':'很遗憾，你未能加入此局', 
          activityCoverPage:picUrl('activity/img/',res.result.activityCoverPage),
        })
        
      }
    })
  },

  //有局app弹框上的按钮事件
  launchAppError(e){
    console.log(7777)
    //复制文字到剪贴板
    launchAppCopy()
  },

  

})